FreePPP Control is a scripting addition which gives Applescript access to the main functions of the FreePPP 2.6 system extension.For more information about FreePPP please visit <http://www.rockstar.com/>.
History
I’ve been using the scripting addition "MacPPP Control" by Mark Aldritt to automate my daily PPP access. It allows Applescript to open and close a specific PPP connection and set or ask for current state informations.
MacPPP Control always worked fine with MacPPP and FreePPP up to version 2.5v2 but the developers of FreePPP changed the API and the structure of the preferences file in a way that it won’t function with FreePPP 2.6. Having some spare time I started to work on my own replacement for the MacPPP scripting addition based on the public interface for FreePPP 2.6.
How to install FreePPP Control
Assuming that FreePPP 2.6 and Applescript are properly installed on your computer you just have to place the "FreePPP Control" Scripting Addition in your "Scripting Additions" Folder which should be located in your "System Extensions" Folder. You don’t have to restart. The new FreePPP Applescript commands are instantly available.
What features does it add ?
FreePPP Control adds six new commands and one new class to your Applescript environment. If you’re starting your scripteditor and open the dictionary of FreePPP Control or simply drag the Scripting addition onto it you will get short informations about the newly added features.
New commands
• open FreePPP: Attempts to open a FreePPP connection
Syntax: open FreePPP
The command takes no arguments and returns no value. It simply tries to open the current PPP connection with the current settings. If there already is an active connection nothing happens.
Note: "open FreePPP" initiates a new connection without waiting for success. If you want to be sure that you have an active connection you have to call "FreePPP is" or "FreePPP state".
• close FreePPP: Attempts to close FreePPP connection
Syntax: close FreePPP
Tries to close the current connection. If there is none nothing happens. As with "open FreePPP" there is no return value. You have to use the "FreePPP is" command or the "FreePPP state" verb to check for success.
Caution: In contrast to the "MacPPP Control" scripting addition there is no way to force a hard close on the current connection. This behavior of FreePPP is strictly controlled by the current FreePPP settings. You can’t rely on "FreePPP Control" to actually close the telephone line for you. It simply closes the PPP stack to your ISP.
• FreePPP is: check if FreePPP is connected or not connected
Syntax: FreePPP is connected/not connected
There are two different ways to use the "FreePPP is"to check for a current connection. If you write "FreePPP is connected" the function returns true if your computer is currently connected otherwise false. A different approach is to ask if the computer is not connected by issuing the "FreePPP is not connected" command. The following statements within the if clause both are executed whenever FreePPP is currently on-line.
if FreePPP is connected then
-- do something very usefull
end if
if not FreePPP is not connected then
-- do something even more usefull
end if
• FreePPP set: set various parameters of FreePPP
Syntax: FreePPP set
the current account/current location/current/modem
to string
The "FreePPP set" command enables Applescript to manipulatesome of the FreePPP settings like the account to use when dialing, the current modem and the present location. It takes two arguments. The first of them has to be introduced by the word "the" and determines the parameter you want to change. The second argument is preceded by "to" and specifies the new value.
There is no return value. If the function failes the command returnes an error to Applescript and the script gets terminated. Valid arguments for new accounts, locations or modems have to be a part of the corresponding list (see "FreePPP get"). Names are case sensitive. The command also failes if there is a current connection.
The following example first checks for FreePPP to be off-line and changes the name of the current modem to "MyBrandNew 56k Modem".
if FreePPP is not connected then
FreePPP set the current modem to "MyBrandNew 56k Modem"
end if
• FreePPP get: get various information from the FreePPP settings
Syntax: FreePPP get
the current account/current location/current modem
the list of accounts/list of locations/list of modems
This command is used to query different settings of FreePPP. It takes one argument which is preceded by "the". There are two different classes of properties you can ask for. (1) If you request the name of the current account, location or modem a single string is returned which represents the name as it can be seen in the FreePPP Setup dialog. (2) If you ask for the list of accounts, locations or modems you'll get a list of strings representing valid names to choose from.
The next example first determines the name of the current location and shows it in a dialog. Afterwards it'll show the list of valid account names one after the other .
set the_account to FreePPP get the current account
display dialog the_account
--
set the_list to FreePPP get the list of accounts
repeat with a in the_list
display dialog a
end repeat
• FreePPP state: get state of the current FreePPP connection
Syntax: FreePPP state
"FreePPP state" returns various information’s about the current PPP connection. The function takes no arguments and returns a record of class FreePPP-State.
New classes
• Class FreePPP-State: Information about the current PPP connection
Properties:
active boolean -- are we currently connected ?
duration integer -- Duration of the connection in seconds
bytes in integer -- Number of bytes in
bytes out integer -- Number of bytes out
local IP a list of small -- IP address of your integer computer
remote IP a list of small -- IP of the remote server integer
This is the only new class defined by the "FreePPP Control" Scripting Addition. The record contains various information about an active PPP connection (if there is any) and it’s only purpose is to serve as a reply type for the "FreePPP state" command.
The boolean value "active" reflects the on-line state of your computer. If it’s false there is no connection. In this case the rest of the properties are not defined and can not be evaluated. Checking the "active" property gives the same result as calling "FreePPP is connected".
The "duration" Property contains the number of seconds since the connection has been opened. "bytes in" and "bytes out" are counters holding the number of bytes written to and read from the PPP Server. The properties "local IP" and "remote IP" are lists of four integers which represent the IP of your computer and the server on the other side of the telephone.
The following example gets the current FreePPP-State, determines if there currently is a connection and shows the local IP if FreePPP is active.
open FreePPP
set a to FreePPP state
--
if active of a then
set IP to ""
--
-- Transform the List into a string with dots
--
repeat with b in local IP of a
set IP to (IP & b as text) & "."
end repeat
--
-- delete the trailing "."
--
set IP to items 1 thru ((number of items of IP)-1) of IP as text
display dialog IP
end if
Error Messages
If something goes wrong the FreePPP Control Applescript addition returns an error message to the scripting system and terminates the script execution. There are (hopefully only) five types of error messages returned by the scripting addition.
• "Neither MacTCP nor OpenTransport seems to be installed on this System."
FreePPP Control wasn’t able to find any TCP/IP connection stack. Every command will terminate with this message if neither MacTCP nor OpenTransport is installed on your Computer.
• "FreePPP 2.6 or higher is not selected in the TCP/IP control pannel."
If OpenTransport is installed but FreePPP 2.6 is not selected as the current connection method some commands will terminate with this error message. "open FreePPP" and "close FreePPP" will fail whereas you’re still able to get and set current settings.
• "Either FreePPP 2.6 is not installed or it's not selected in the MacTCP control pannel."
If MacTCP provides the TCP/IP stack all commands require FreePPP to be the current connection method and will abort the script with this message.
• "Command is illegal while FreePPP is connected"
You tried to set a new name for account, modem or location while the PPP connection was active. FreePPP Control is not able to change these parameters while on-line.
• "Bad name for [account/location/modem]"
This message is triggered by an attempt to change the current modem, location or account name to something not listed in the FreePPP settings. Please keep in mind that these names are case sensitive. The best strategy to circumvent this message is to take a name out of the list obtained by the "FreePPP get" command.
FreePPP Control is a beta release
FreePPP Control 1.0b2 is a beta release.It is expected to be buggy. I’ve been testing the program thoroughly but I don’t have the time to do this checking on various hardware platforms with different system configurations. Please keep me informed if there is any misbehavior of my program.
You can reach me via e-mail under <kloska@mpimg-berlin-dahlem.mpg.de>. Or visit my homepage <http://www.snafu.de/~sebastian.kloska/>
FreePPP Control is Freeware
You may use FreePPP Control free of charge make as many copies as you like and distribute it on a non profit basis as long as it stays bundled with this unaltered documentation. For-profit companies that sell software programs must receive explicit written permission from the author before distributing the program.
Version History
• 1.0b1 (30.Juli.1997)
First public release of FreePPP Control
• 1.0b2 (16.Aug.1997)
Replaced a wrong error message. Little improvement on the documentation.
Disclaimer
I make no warranty whatsoever, either implied or expressed, as to the correct functioning of this software. When using this software, the user assumes all responsibility for any damages caused, directly or indirectly, by its use.
Sebastian Kloska; Katzlerstr 19;10829 Berlin;Germany
mailto:kloska@mpimg-berlin-dahlem.mpg.de
http://www.snafu.de/~sebastian.kloska/
FreePPP , the FreePPP Icon and FreePPP Setup are copyrights owned by the FreePPP Group Inc.
Applescript is a registered trademarks of Apple Computer, Inc.